package cc.deng.wubo.minapp.service.impl;


import cc.deng.wubo.minapp.beans.SysRole;
import cc.deng.wubo.minapp.beans.SysUser;
import cc.deng.wubo.minapp.core.base.BaseServiceImpl;
import cc.deng.wubo.minapp.service.RoleService;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/3/17.
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<SysRole> implements RoleService {
    @Autowired
    public RoleServiceImpl(Dao dao) {
        super(dao);
    }
   /* @Autowired
    private Dao dao;*/

  /*  @Autowired
    public RoleServiceImpl(Dao dao) {
        super(dao);
    }*/

    @Override
    public List<SysRole> findByUserId(Integer id) {
        SysUser user = this.dao().fetchLinks(this.dao().fetch(SysUser.class, id), "roles");

        List<SysRole> roles = user.getRoles();
        return roles;
    }

    @Override
    public SysRole findById(Integer id) {
        SysRole role = this.fetch(id);

        return role;
    }
}
